package com.example.gitproject.WebConfig;

import com.example.gitproject.Interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {


    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/backend/login").setViewName("/backend/login.html");
        registry.addViewController("/backend/upload").setViewName("/backend/fileupload.html");
    }



    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
         registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/");
         registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
    }

    //注册拦截器
//    @Override
//    public  void addInterceptors(InterceptorRegistry registry) {
//        //addPathPatterns 拦截指定路径  /**  当前目录所有路径      excludePathPatterns 除外
//        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/backend/login.html");
//    }




}
